function mapSearchs(cinemaId){
	var url_remote = "/jquery-first050.html?cinemaId="+cinemaId+"&routetype=1&datatype=map";
	location.href=url_remote;
	//$.post(url_remote, null);//{"cinemaId":cinemaId,"routetype":1,"datatype":"map"}
}
/***
 * 展示个人信息
 * @param customerid
 */
function showInfo(customerid){
	var url_remote =  ticket_host+"/jquery-first045.html?customerid=" + customerid+"&type=star";
	var bool  = "";
	$.post(url_remote, null, function(data){
		var items = data.getElementsByTagName("item");
		var flag = items[0].childNodes[0].nodeValue;
		if(flag==0){
			bool = items[1].childNodes[0].nodeValue;
			$(".faceawall").html(bool);
			$(".close").click(function(){
				closeFaceWalls();
			});
			$(".mask").click(function(){
				closeFaceWalls();
			});
			$(".faceawall .pic li").JNMagnifier({
				renderTo : ".ShowBigPictureBox"
			});
		}else{
			$(".faceawall").html(bool);
		}
		
	});		
	if($(".mask").length<=0){
		$("body").append("<div class='mask' style='display:none'></div>");
	}
	$(".mask").show();
	$(".faceawall").show();
}
function closeFaceWalls(){
	$(".faceawall").hide();
	$(".mask").hide();
};
/***
 * 字数限制
 * @param i
 * @returns {Boolean}
 */
function textareaMaxlength(i){
   var comment=comment = $("#filmcontent"+i).val();
   comment = comment.replace(/\s+/g,""); 
  if(comment.length > 1000){  
	  $("#fcontent"+i).html((1000-comment.length)>0? (1000-comment.length):"0");
	  var outlength = comment.length-1000;
	  $("#outlength"+i).html("您已超出<span class=\"red\">"+outlength+"</span>个字");
    return false;
  }  
  $("#fcontent"+i).html((1000-comment.length)>0? (1000-comment.length):"0");
  $("#outlength"+i).html("");
} 
/***
 * 蜘蛛分页
 * @param pagesize
 */
function getNextPage(pagesize){
	var filmId = $("#filmId_hidden").val();
	var url="/jquery-second036.html?pagesize="+pagesize+"&filmId="+filmId;
	$.post(url,null,function(data){
		 var items = data.getElementsByTagName("item");
			var flag = items[0].childNodes[0].nodeValue;
			if(flag == 0){
				var html =items[1].childNodes[0].nodeValue;
				$("#tusi").html(html);
			}
	})
}
/***
 * 资讯点评
 * @param id
 * @param i
 * @param obj
 */
function addfavorite(id,i,obj){
	var filmId = $("#filmId_hidden").val();
	var url="/jquery-second019.html?noticeId="+id+"&filmId="+filmId;
	$.post(url,null,function(data){
	   	var items = data.getElementsByTagName("item");
        var message = items[0].childNodes[0].nodeValue;
        if(message=="login"){
        	 onclickLogin();
        }else{
        	var result = items[1].childNodes[0].nodeValue;
        	var count=document.getElementById("useracount_"+i).innerHTML;
			if(result=="0" || result==0 ){
				addOne(obj);
				//document.getElementById("useracount_"+i).innerHTML = parseInt(count)+1;	
			}else{
				alert(message);
			}
        }
         	
         	
	});
}
/***
 * 提交评分
 */
 function addScore(){
	  var t="";
	  var filmId = $("#filmId_hidden").val();
	  var token = $("#token").val();
	   for (i = 1; i <= 5; i++) {
		var con = document.getElementById("j_three_" + i);
		if(con.style.display=='block'){
		  t=i;
		}
	   }
	   if(t==""){
		   tipsWindownNew("请选择评分项！" , "480", "200", "0" );
		   return;
	   }
	   var score = t*2;
	   var url="/jquery-second035.html?filmId="+filmId+"&score="+score+"&token="+token;
	   $.post(url, null, function(data){
		   var dt=data.split(",");
		   if(data == "false"){
			   tipsWindownNew("提交失败,请刷新重试！" , "480", "200", "0" );
			}else if(dt[0] == "outcount"){ //超过点击次数
				$("#token").val(dt[1]);
				tipsWindownNew("亲，你已经点过一次了！明天再来吧！" , "480", "200", "0" );
			}else{
				$("#token").val(data);
				tipsWindownNew("提交成功！" , "480", "200", "0" );
			}
	   });
	  }
/***
 * 短评点击事件
 * @param id 被顶评论id
 * @param title
 * @param star
 * @param content 
 * @param obj 
 */
function addfcomment(id,title,star,content,obj){
    var filmId = $("#filmId_hidden").val();
    var token = $("#token").val();
    var url_remote = ticket_host+"/jquery-second034.html?filmId="
     + filmId+"&star="+star+"&commentid="+id+"&token="+token;
    url_remote = encodeURI(url_remote);
	 $.post(url_remote, {"ctype":"s","comment":encodeURI(content),"title":encodeURI(title)}, function(data){
		var dt=data.split(",");
		if(data == "login"){
			loginDiv();
		}else if(dt[0] == "outcount"){
			//$(".black")[0].style.display='block';
			$("#token").val(dt[1]);
			tipsWindownNew("亲，你已经点过5次了！" , "480", "200", "0" );
		}else if(data == "false"){
			tipsWindownNew("发表评论失败，请刷新重试！" , "480", "200", "0" );
		}else{
				var dt=data.split(",");
				$("#fscount").html(dt[0]);
				$("#dscount").html(dt[1]);
				$("#token").val(dt[2]);
				addOne(obj);
		}
	 });

}
/***
 * 浮动效果
 * @param obj
 */
function addOne(obj){
	var color;
	var dataTag=obj.attr("data-tag");
	if(obj.hasClass("blueTag")){
		color='#6e7aa0';
	}
	else{
		color='#e71204';
	}
	$(".userTag").removeClass("on");
	var TheTag=$(".userTag[data-tag="+dataTag+"]");
	TheTag.addClass("on");
	var clcNum=obj.find("span");
	var num=parseInt(clcNum.text())+1;
	var newNum=clcNum.clone();
    newNum.text("+1"); 
	newNum.css({
		'z-index': 1000,
		'position': 'absolute',
		'color':color,
		'top': clcNum.offset().top-13 + 'px',
		'left': clcNum.offset().left + 'px'
	});
	$('body').append(newNum);
	newNum.animate({
		top: clcNum.offset().top - 24
	}, 400, "linear", function() {
		newNum.hide().remove();
	});
	setTimeout(function(){
		TheTag.find("span").text(num);
	},500)	
}
/***
 * 发表评论
 * @param title 评论标题
 * @param star  评分
 * @param ctype 长评/短评
 * @param i 第几个文本框
 * @returns {Boolean}
 */
function addfilmShortcomment(title,star,ctype,i){
     var comment = "";
     var filmId = $("#filmId_hidden").val();
     var cinemaId = $("#cinemaId").val();
     var token = $("#token").val();
     var outhtml = "话唠吗？我这里装不下耶，您可以去<a href=\"#datecontent\" class=\"bules_a\" onclick=\"setTab1('onet',1,4)\">发布长评</a>，或者重新思考下人生。";
     if(ctype == "s"){
    	 comment = $("#shortcomment_key").val();
    	 comment = comment.replace(/\s+/g,""); 
    	 if(comment =="" || comment =="厉害就不要超过10个字" || comment==null){
       	  alert("评论内容不能为空哦！");
  		  return false;
        }else if(comment.length > 10){
        	 $("#outlength").html("<span class=\"redff\">一字千金，提炼下，10个字！</span>");
        	 $("#outlength").show();
        	 return false;
         }else{
        	 $("#outlength").html(outhtml);
        	 $("#outlength").hide();
         }
     }else{
    	 comment = $("#filmcontent"+i).val();
    	 comment = comment.replace(/\s+/g,"");
    	 if(comment =="" || comment =="其实我是从很严谨的学术角度来评价这部电影的..." || comment==null){
          	  alert("评论内容不能为空哦！");
     		  return false;
     	  }else if(comment.length<6){
        	  alert("评论内容至少含有6个中文字.");
   		  return false;
         }else if(comment.length>1000){
        	  alert("评论内容不能大于1000字哦！");
   		  return false;
         }
     }
     var url_remote = ticket_host+"/jquery-second034.html?filmId="
      + filmId+"&star="+star+"&cinemaId="+cinemaId;
     url_remote = encodeURI(url_remote);
	 $.post(url_remote, {"ctype":ctype,"comment":encodeURI(comment),"title":encodeURI(title),"token":token}, function(data){
		 var dt=data.split(",");
		if(data == "login"){
			loginDiv();
		}else if(data == "filter"){ //敏感词过滤
			tipsWindownNew("您发布的内容带有违禁词，节操何在？请修改后重新发布" , "480", "200", "0" );
		}else if(data == "false"){
			tipsWindownNew("发表评论失败，请刷新重试！" , "480", "200", "0" );
		}else if(data == "success"){ //长评提交成功
			tipsWindownNew("提交成功！看来很有见谛！" , "480", "200", "0" );
			 $("#filmcontent"+i).val("");
		}else if(dt[0] == "outcount"){ //发布次数超过5次
			$("#outlength").show();
			$("#token").val(dt[1]);
			tipsWindownNew("亲，你已经发布5次了！明天再来吧！" , "480", "200", "0" );
		}else{  //短评提交成功
			tipsWindownNew("总结非常到位！" , "480", "200", "0" );
			var dt=data.split(",");
			$("#fscount").html(dt[0]);
			$("#dscount").html(dt[1]);
			$("#token").val(dt[2]);
		    $("#shortcomment_key").val("");
		    setTimeout(function(){
		    	$(".popup").hide();
		    	$(".mask").hide();
		    	location.href=ticket_host+"/film-"+filmId+"#six1";
		    	setTab1('six',1,2);
		    },2000)
		}
	 });
}

/***
 * 行政区切换
 * @param obj
 */
function regionChange(obj){
   $("#regionId_hidden").val($(obj).attr("name"));
   $("#subwayId_hidden").val("");
   $("#cinemaId_hidden").val("");
   $("#txtId_hidden").val("");
   $("#cinemakey").val("快速搜索影院");
   $("#cinemakey").attr("style","color: rgb(153, 153, 153)");
  jquerysubmit("xzq"); 
}
/***
 * 地铁线切换
 * @param obj
 */
function subwayChange(obj){
   $("#subwayId_hidden").val($(obj).attr("name"));
   $("#regionId_hidden").val("");
    $("#cinemaId_hidden").val("");
    $("#txtId_hidden").val("");
    $("#cinemakey").val("快速搜索影院");
    $("#cinemakey").attr("style","color: rgb(153, 153, 153)");
   jquerysubmit("dtxl"); 
}
/***
 * 特效厅切换
 * @param obj
 */
function txhallChange(obj){
   $("#txtId_hidden").val($(obj).attr("name"));
   $("#regionId_hidden").val("");
    $("#subwayId_hidden").val("");
    $("#cinemaId_hidden").val("");
    $("#cinemaname_hidden").val("");
    $("#cinemakey").val("快速搜索影院");
   $("#cinemakey").attr("style","color: rgb(153, 153, 153)");
   jquerysubmit("txt"); 
}
/***
 * 影院切换
 * @param obj
 */
function cinemaChange(obj){
   $("#cinemaId_hidden").val($(obj).attr("name"));
   var type=$("#type").val();
   $("#cinemakey").val("快速搜索影院");
   $("#cinemakey").attr("style","color: rgb(153, 153, 153)");
   if(type != null && type != ""){
	   jquerysubmit(type); 
   }else{
	   jquerysubmit("cinema"); 
   }
}
/***
 * 快速搜索
 */
function quickSearch(){
	var cinemaname =$("#cinemakey").val().replace(/\s+/g,"");
	if(cinemaname == "快速搜索影院" || cinemaname == ""){
	  $("#cinemaname_hidden").val("");
	  return;
	}else{
	  $("#cinemaname_hidden").val(cinemaname);
	}
	$("#hidemenu").hide();
	setTab1('two',0,6);
	  $("#type").val("");
	  $("#cinemaId_hidden").val("");
	  jquerysubmit("cinemasearch");

}
/**评论分页
 * @param pagesize:每页条数
 * @param i:当前页数
 * @param ctype:长评/短评 l/s
 * **/
function pager(pagesize,i,ctype){
	var filmId = $("#filmId_hidden").val();
	var fscount = $("#fscount").val();
	var dscount = $("#dscount").val();
	var url="/jquery-second037.html?filmId="+filmId+"&currentPage="+i+"&pagesize="+pagesize+"&ctype="+ctype;
	$.post(url,{"fscount":fscount,"dscount":dscount},function(data){
		var items = data.getElementsByTagName("item");
		var flag = items[0].childNodes[0].nodeValue;
		if(flag == 0){
			var filmcommenthtml = items[1].childNodes[0].nodeValue;
			var pagerhtml = items[2].childNodes[0].nodeValue;
			pagerhtml = pagerhtml.replace("window.location.hash='#ypdp'","goTo('#ypdp')");
			pagerhtml = pagerhtml.replace("window.location.hash='#six1'","goTo('#six1')");
			filmcommenthtml = filmcommenthtml.replace("window.location.hash='#ypdp'","goTo('#ypdp')");
			filmcommenthtml = filmcommenthtml.replace("window.location.hash='#six1'","goTo('#six1')");
			//pagerhtml = pagerhtml.replace("fl fs0 ml10 mt20","fl fs0 ml10 mt20 w170");
			//filmcommenthtml = filmcommenthtml.replace("fl fs0 ml10 mt20","fl fs0 ml10 mt20 w170");
			pagerhtml = pagerhtml.replace(new RegExp(/(fl fs0 ml10 mt20)/g),'fl fs0 ml10 mt20 w170');
			filmcommenthtml = filmcommenthtml.replace(new RegExp(/(fl fs0 ml10 mt20)/g),'fl fs0 ml10 mt20 w170');
			if("l" == ctype){
				$("#longcomment").html(filmcommenthtml);
				$("#longcommentpager").html(pagerhtml);
				$("#longcomment2").html(filmcommenthtml);
				$("#longcommentpager2").html(pagerhtml);
			}else{
				$("#shortcomment").html(filmcommenthtml);
				$("#shortcommentpager").html(pagerhtml);
			}
		}
	});
}
/***
 * 样式切换
 * @param o
 * @param style
 * @param ids
 */
function changeClass(o,style,ids){
	$(o).addClass(style);
	var name = $(o).attr("name");
		$(ids).each(function(index ,obj){
			if(name!=$(obj).attr("name")){
				$(this).removeClass(style);
			}
		});
}


/**显示场次活动*/
function showactivity(o){
	
    var now=$(o);
	var hd_now=now.parents("tr").next("tr").find(".btn_td");
	var jt_now=now.parents("tr").find(".sj");
    if(now.find("span").hasClass("joyyou1")){ //隐藏
    	now.parents("table").find(".sj").hide();
    	now.parents("table").find(".btn_td").hide();
    	now.parents("table").find(".joyyou").attr("class","joyyou1");
    	now.parents("table").find(".h").removeClass("h1");
    	
		hd_now.show();
		jt_now.show();
   	    now.find("span").removeClass("joyyou1").addClass("joyyou");
   	    now.addClass("h1");
		}
    else{	//展示
		hd_now.hide();
		jt_now.hide();
		now.find("span").removeClass("joyyou").addClass("joyyou1");
		now.removeClass("h1");
		}
}


/***
 * 座位缩略图
 * @param seqno
 */
function showseatlist(seqno){
	  	outseatlist();
		var url = ticket_host + "/jquery-first026.html?id="+seqno;
		$.post(url,null,function(data){
		    var result = data.getElementsByTagName("item");
		    var bool = result[0].childNodes[0].nodeValue;
		    var $tip=$(bool);
			$("body").append($tip);			
		})
	}
	function moveseatlist(event){
	   $("#tip").show();
	   var posX = event.pageX ? event.pageX : event.x;
	   var posY = event.pageY ? event.pageY : event.y;
	   $("#tip").css({"top":posY-30+"px","left":posX+30+"px"});
	}
	function outseatlist(){
	  $("#tip").remove();
	}

	var flag = false;
/***
 * 公用切换提交方法
 * @param type
 */
function jquerysubmit(type){
       var filmId = $("#filmId_hidden").val();
	    var showDate = $("#showDate_hidden").val();
	    var area = $("#area_hidden").val();
	    var regionId = $("#regionId_hidden").val();
	    var subwayId = $("#subwayId_hidden").val();
	    var txtId = $("#txtId_hidden").val();
	    var cinemaId = $("#cinemaId_hidden").val();
	    var cinemaname = $("#cinemaname_hidden").val();
	    var customerid=$("#customerid").val();
		var url=ticket_host+"/jquery-second033.html?filmId="+filmId+"&showDate="+showDate+"&area="+area+
		"&type="+type+"&regionId="+regionId+"&subwayId="+subwayId+"&cinemaId="+cinemaId;
		$.post(url,{"cinemaname":cinemaname,"txtId":txtId},function(data){
		    var items = data.getElementsByTagName("item");
			var flag = items[0].childNodes[0].nodeValue;
			if(flag == 0){
				 var regionhtml = items[1].childNodes[0].nodeValue;
				 var subwayhtml = items[2].childNodes[0].nodeValue;
				 var txthtml = items[3].childNodes[0].nodeValue;
				 var cinemahtml = items[4].childNodes[0].nodeValue;
				 var cinemainfo = items[5].childNodes[0].nodeValue;
				 var showhtml = items[6].childNodes[0].nodeValue;
				 var wcqcinema = items[7].childNodes[0].nodeValue;
				 var youhui = items[8].childNodes[0].nodeValue;
				 var cinemadetail = items[9].childNodes[0].nodeValue;
				 //var txthallinfo = items[8].childNodes[0].nodeValue;
				 $(".film_cinema").html(cinemahtml);
				 $(".details_showtwo").html(showhtml);//details_showtwo
				 $("#tempcinema").html(cinemainfo);
				 $("#j_two_2").html(regionhtml);
				 $("#j_two_3").html(subwayhtml);
				 $("#j_two_5").html(txthtml);
				 $("#youhui").html(youhui);
				 $("#cinemadetail").html(cinemadetail);
				 $(".film_cinema").css("opacity",0).animate({opacity:'1'},300);
				 $(".details_showtwo").css("opacity",0).animate({opacity:'1'},300);
				 $(".tempcinema").css("opacity",0).animate({opacity:'1'},300);
				 $(".details_sh").hide();
				 if("date"==type){
					 
					 if(wcqcinema == ""){
						 $("#two4").hide();
						 //$("#two4")[0].style.display='none';
						 $("#two1").addClass("hover");
						 $("#type").val("");
					 }else{
						 $("#two4").show();
						 //$("#two4")[0].style.display='block';
						 if(customerid != "null" && customerid != ""){
							 $("#two4").addClass("hover");
							 $(".film_cinema").html(wcqcinema);
							 $("#type").val("wcq");
						 }else{
							 $("#two1").addClass("hover");
						 }
					 }
					 if(txthtml == ""){
						 $("#two5").hide();
						 //$("#two5")[0].style.display='none';
					 }else{
						 $("#two5").show();
						// $("#two5")[0].style.display='block';
					 }
					 if(showhtml == null || showhtml == ""){//如果热门没有数据，默认展示行政区
						 setTab1('two',2,6);
						 $("#hidemenu").show();
						 $("#two1").hide();
				  		    $("#subwayId_hidden").val("");
				  		    $("#txtId_hidden").val("");
				  		    $("#cinemaId_hidden").val("");
				  		    $("#cinemaname_hidden").val("");
				  		    $("#cinemakey").val("快速搜索影院");
				  		    var regionname = $("#j_two_2 a:eq(0)").attr("name");
				  		    $("#regionId_hidden").val(regionname); 
				  		    $("#type").val("");
				  		   jquerysubmit("xzq");
					 }
					
				 }
				 if(cinemahtml !=null && cinemahtml!=""){
					 $("#cinemalists").show();
					 $("#nocinema").hide();
				  //$("#cinemalists")[0].style.display='block';
				  //$("#nocinema")[0].style.display='none';
				 }else{
					 $("#cinemalists").hide();
				  //$("#cinemalists")[0].style.display='none';
				  if("cinemasearch" == type){
					  $("#nocinema").show();
					  //$("#nocinema")[0].style.display='block';
				  }
				 }
				 if($("#two1").css('display')=="none"){
			    	 $("#bluejt1").removeClass("bluejt1");
			    	 $("#bluejt2").removeClass("bluejt2");
			    	 $("#bluejt3").removeClass("bluejt3");
			    	 $("#bluejt1").addClass("bluejt");
			    	 $("#bluejt2").addClass("bluejt1");
			    	 $("#bluejt3").addClass("bluejt2");
			    }
			}
			
		});
		
}